import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  server: {
    proxy: {
      '/store': {
        target: 'http://192.168.31.100:8888',
        // 允许跨域
        // changeOrigin: true,
        // 重写路径，去掉 /store 前缀
        rewrite: (path: string) => path.replace(/^\/store/, ''),
      },
    },
  },
  plugins: [vue(), vueDevTools()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
})
